home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pbaseiv.zip / P4UTL002.TIP < prev    next >
Text File  |  1991-12-16  |  2KB  |  73 lines

  1. Many batch files change the current directory on one or more
  2. of your system's drives. Unfortunately, there's no way for a
  3. batch file to know what directory you're in when you run it,
  4. and therefore no way for it to return to its directory of
  5. origin.
  6.  
  7. That is, until now. I've written a short assembly language
  8. program, BACK.COM, that lets batch files do just that. The
  9. program saves the current directory's path in a
  10. directory-changing batch file. By putting this command at
  11. the beginning of a batch file and--via the CALL
  12. command--running the batch file it creates at the end,
  13. you'll ensure that your batch file will always start and end
  14. in the same directory, regardless of where it goes in
  15. between.
  16.  
  17. Charles N. Jackson III
  18. Silver Spring, Maryland
  19.  
  20. Editor's note: I rewrote BACK.COM to make it smaller and
  21. more bulletproof, then added it to some of my batch files,
  22. where it worked wonderfully. At that point, I realized I
  23. wanted a second, similar utility; one that would return me
  24. to the drive I was logged on to before the batch file ran. I
  25. created another program, BACKD.COM, which generates a batch
  26. file to accomplish this. As with BACK.COM, you put BACKD.COM
  27. at the beginning of your batch file and the file it creates
  28. at the end.
  29.  
  30. BACK.COM and BACKD.COM are both included, in executable
  31. form, in the P4UTIL directory on your PowerBase *.* Volume
  32. IV diskette.
  33.  
  34. The following listing shows how to use both BACK.COM and
  35. BACKD.COM. (You can copy the listing to a file by pressing
  36. the Alt-F key.) Note that you can use BACK.COM several times
  37. to restore the original directory on any number of drives.
  38. On the other hand, you need to use BACKD.COM only once--to
  39. restore the original drive before the batch ends.
  40.  
  41.  
  42. Using BACK.COM and BACKD.COM
  43.  
  44. ---- BEGIN LISTING ----
  45. @ECHO OFF
  46. REM Save the current drive
  47. BACKD > D:\DRIVE.BAT
  48. REM Save current directories of drives
  49. REM C: and D:
  50. C:
  51. BACK > D:\CBACK.BAT
  52. D:
  53. BACK > D:\DBACK.BAT
  54. REM Run WordPerfect from drive D:
  55. REM and pass it the command line parameters
  56. CD \WP51 /w=* /d=d:\ %1 %2 %3 %4
  57. REM Restore everything
  58. CALL D:\CBACK.BAT
  59. CALL D:\DBACK.BAT
  60. CALL D:\DRIVE.BAT
  61. REM Clean up
  62. DEL D:\CBACK.BAT > NUL
  63. DEL D:\DBACK.BAT > NUL
  64. DEL D:\DRIVE.BAT > NUL
  65. ECHO ON
  66. ---- END LISTING ----
  67.  
  68. Title: Finding Your Way Back Home
  69. Category: DOS
  70. Issue Date: Dec 1991
  71. Editor: Brett Glass
  72. Supplementary files: P4UTIL\BACK.COM, P4UTIL\BACKD.COM
  73.